<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/26
 * Time: 15:45
 */
namespace app\console\validate;

use think\Validate;

class Goods extends Validate
{
    protected $rule = [
        'title'         => 'require|max:255',
//        'content'       => 'require',
        'status'   => 'require|number|egt:0',
        'cid'   => 'require|number|egt:0',
//        'thumbnails'    => 'require|array|checkImg'
    ];

    protected $message  =   [
        'title.require'             => '标题必须填写',
        'content.require'           => '内容必须填写',
        'status.require'            => '状态必须选择',
        'status.number'             => '状态类型错误',
        'status.egt'                => '状态不合法',
        'cid.require'               => '分类必须选择',
        'cid.number'                => '分类类型错误',
        'cid.egt'                   => '分类不合法',
    ];

    // 自定义验证规则
    protected function checkImg($value)
    {
        return !empty(array_filter($value)) ? true : '请选择图片';
    }

    protected $scene = [
        'edit'  =>  ['title', 'content', 'cid', 'price',],
    ];
}